<template>
	<view class="card" @tap="toliveDetail(item)">
		<view class="hearder">
			<!-- <view class="via">
				<image class="img" :src="item.userPic" mode=""></image>
			</view> -->
			<view class="title">
				<view class="live_title">
					<text>{{item.name}}</text>
				</view>
				<view class="live_user">
					<!-- <text class="name">{{item.username}}</text> -->
					<text>{{item.startTime}} ~ {{item.endTime}}</text>
					<text class="navBtn" @tap.stop="toDetail(item)">查看详情</text>
				</view>
			</view>
			<view class="tabs" :class="{ loading: item.status == 'ONGOING', end: item.status == 'CLOSED' }">
				<text>{{statusLabel(item.status) }}</text>
			</view>
		</view>
		<!-- <view class="desc">
			<text>{{item.desc}}</text>
		</view> -->
	</view>
</template>

<script>
	export default {
		name:"liveCard",
		props:{
			item:{
				type:Object,
				default:()=>{}
			}
		},
		data() {
			return {
				liveStatus:[
				  {value: "ONGOING", label: "直播中" },
				  {value: "NOT_StARTED", label: "未开始" },
				  {value: "CLOSED", label: "已结束" },
				  {value: "BANNED", label: "已禁播" },
				]
			};
		},
		methods:{
			statusLabel(v) {
				return this.liveStatus.find(i=>i.value == v).label
			},
			toliveDetail(item){
				uni.navigateTo({
					url:"/pages/tabbar/live/liveDetail?val=" + JSON.stringify(item)
				})
			},
			toDetail(item){
				uni.navigateTo({
					url:"/pages/mine/live/broad?val=" + JSON.stringify(item)
				})
			}
		}
	}
</script>

<style lang="scss">
	.img{
		width: 100%;
		height: 100%;
	}
	.card{
		padding: 24rpx;
		box-shadow: 0px 0px 6px rgba(0,0,0,0.08);
		background: #FFFFFF;
		border-radius: 8px;
		position: relative;
		margin-bottom: 32rpx;
		.hearder{
			display: flex;
			align-items: center;
			margin-bottom: 24rpx;
			.title{
				width: 100%;
			}
			.via{
				width: 120rpx;
				height: 120rpx;
				margin-right: 16rpx;
			}
			.live_title{
				font-size: 32rpx;
				font-family: Source Han Sans CN;
				color: #3E3E3E;
				margin-bottom: 24rpx;
			}
			.live_user{
				font-size: 24rpx;
				font-family: Source Han Sans CN;
				color: #9D9D9D;
				display: flex;
				justify-content: space-between;
				.navBtn{
					color: #2F7DE7;
				}
			}
			.tabs{
				width: 132rpx;
				height: 46rpx;
				color: #fff;
				font-size: 24rpx;
				background: #FAAD39;
				border-radius: 0px 8px 0px 8px;
				text-align: center;
				line-height: 46rpx;
				position: absolute;
				top: 0;
				right: 0;
			}
			.loading{
				background: #49AE9C;
			}
			.end{
				background-color: #C1C0BE;
			}
		}
		.desc{
			font-size: 28rpx;
			color: #666666;
		}
	}
</style>